<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../style/css.css"/>
<title>仓库首页</title>
</head>
<body>
  <div id="show" class="center">
  	<div class="bnt">
  		<a><input type="button"  value="添加化妆品信息" onclick="window.open('addCos.jsp')"/></a>
  		<a><input type="button"  value="添加库存信息" onclick="window.open('addDep')"/></a>
  	</div>
  	<div class="select">
  	<form action="CosDep" method="post">
  		<table>
  		   <tr><td>化妆品名称：</td>
  		  	   <td><input type="text" name="cosmeticName"/></td>
  		       <td>化妆品厂家：</td>
  		       <td><input type="text" name="Manufacturer "/></td>
  		       <td rowspan="2"><input type="submit" value="查询"/></td>
  		   </tr>
  		   <tr><td>操作类型：</td>
  		       <td><input type="checkbox" name="op_type" value="入库" id="ruku"/><label for="ruku">入库</label>
  		   	       <input type="checkbox" name="op_type" value="出库" id="chuku"/><label for="chuku">出库</label></td>
  		   		<td>销售时间(年)：</td>
  		   		<td><input type="text" name="in_time"/></td></tr>
  		</table>
  		</form>
  	</div>
  	<div>
	  <table>
	    <tr><th colspan="6" >化妆品库存信息页面</th></tr>
	    <tr><th >化妆品名称</th><th>价格</th><th>操作数量</th><th>操作时间</th><th>操作类型</th><th>厂家</th><th></th><th>操作</th></tr>
	    <c:forEach var="i" items="${lc}">	    	
	    <tr>
	    <td>${i.cosmeticName}</td>
		<td>${i.cosmeticPrice}</td>	
		<td>${i.depotCount }</td> 
		<td>${i.inTime}</td>  
		<td>${i.opType}</td> 
		<td>${i.manufacturer}</td>
		<th></th>
		<td><a href="#" onclick="show(${i.depotInfoId})">详情</a>/
		<a href="delCosDep/?id=${i.depotInfoId}&curpage=${curpage}" onclick="return confirm('确定删除？')">删除</a></td>
	    </tr>
	    </c:forEach>
	    <tr><td colspan="7" align="right">
	    <c:forEach var="i" begin="1" end="${pages}">
	    	<c:choose>
	    	<c:when test="${i-1==curpage}">
	    	<span style="color: red"><a href="${i}">${i}</a></span>
	    	</c:when>
	    	<c:otherwise>
	    	<span><a href="${i}">${i}</a></span>
	    	</c:otherwise>
	    	</c:choose>
	    </c:forEach>
	    </td>
	    </tr>
	  </table>
  	</div>
  </div>
  <script type="text/javascript">
  	function show (id) {
  		$.ajax({
  			type:"get",
  			url:"updateCosDep?id="+id,
  			success:function(data){
  				var data=$.parseJSON(data);
  				var srt="<form><table>";
  				$.each(data, function(key,val) {
  					str+="<tr><td></td><td><input type='text' name='"+key+"' value='"+val+"'/></td></tr>";
  				});
  			 ayer.open({
  			 type:1,
  			 title:'修改库存详情',
  			 area:['600px','400px'],
  			 shadeClose:false,
  			 content:srt
  			 });
  			}
  		});
  	} 	
  </script>
  
</body>
</html>